package hongcaosp.app.android.search;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import hongcaosp.app.android.R;
import hongcaosp.app.android.common.BaseHolder;
import hongcaosp.app.android.modle.bean.Video;
import xlj.lib.android.base.utils.GlideUtils;
import xlj.lib.android.base.view.OnRecycleItemClickListener;

public class SearchVideoHolder extends BaseHolder<Video> {
    private Context context;
    private ImageView coverIV,userLogo;
    private TextView videoDes,userName,likeCount;

    public SearchVideoHolder(Context context, OnRecycleItemClickListener recycleItemClickListener) {
        super(LayoutInflater.from(context).inflate(R.layout.item_search_video,null), recycleItemClickListener);
        this.context = context;
        coverIV = itemView.findViewById(R.id.place_holder);
        userLogo = itemView.findViewById(R.id.user_logo);
        videoDes = itemView.findViewById(R.id.video_desc);
        userName = itemView.findViewById(R.id.user_name);
        likeCount = itemView.findViewById(R.id.like_count);
    }

    @Override
    public void setData(Video video) {
        super.setData(video);
        Glide.with(context).load(video.getVideoImage()).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(coverIV);

        if (video.getAuthor() != null) {
            GlideUtils.loadCircleImage(context,video.getAuthor().getUserLogo(),userLogo,R.drawable.icon_head);
            userName.setText(video.getAuthor().getUserName());
        }
        videoDes.setText(video.getAppComments());
        likeCount.setText(video.getLikeCount() + "");
    }
}
